import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error=> error)
}

import MainChildren from './main' // 主内容 子路由

const router = new Router({
    routes: [
        {   /* 主页 */
            path: '/',
            redirect: '/Sigin' // 路由重定向
        },
        // 登录
        {
            path: '/Sigin',
            // 路由懒加载 () => import(url)
            component: () => import('../pages/Sigin/sigin.vue')
        },
        // 主要内容
        {
            path: '/Main',
            component: () => import('../components/Main.vue'),
            children: MainChildren
        },
        // 路由未找到 跳转至404页面
        {
            path: '*',
            component: () => import('../components/404.vue')
        }
        
    ]
})
export default router